//
//  WHYStatusCellBottomView.swift
//  WHYWeibo-1.0
//
//  Created by 王洪运 on 15/11/25.
//  Copyright © 2015年 王洪运. All rights reserved.
//

import UIKit

class WHYStatusCellBottomView: UIView {
    
    
//    MARK: - 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    MARK: - 懒加载子控件
    /// 转发按钮
    private lazy var forwardButton: UIButton = UIButton(title: "转发",
        color: UIColor.lightGrayColor(),
        fontSize: 12,
        imageName: "timeline_icon_retweet")
    /// 评论按钮
    private lazy var commentButton: UIButton = UIButton(title: "评论",
        color: UIColor.lightGrayColor(),
        fontSize: 12,
        imageName: "timeline_icon_comment")
    /// 点赞按钮
    private lazy var likeButton: UIButton = UIButton(title: "赞",
        color: UIColor.lightGrayColor(),
        fontSize: 12, imageName: "timeline_icon_unlike")

}

// MARK: - 搭建UI
extension WHYStatusCellBottomView {
    
    private func setupUI () {
        
        backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        
        addSubview(forwardButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        forwardButton.snp_makeConstraints { (make) -> Void in
            make.left.top.bottom.equalTo(self)
        }
        
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(forwardButton)
            make.left.equalTo(forwardButton.snp_right)
            make.size.equalTo(forwardButton)
        }
        
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton)
            make.left.equalTo(commentButton.snp_right)
            make.right.equalTo(self)
            make.size.equalTo(commentButton)
        }
        
        //MARK: - 分隔符
        let sepLeft = sepView()
        let sepRight = sepView()
        addSubview(sepLeft)
        addSubview(sepRight)
        
        sepLeft.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(forwardButton)
            make.left.equalTo(forwardButton.snp_right)
            make.width.equalTo(0.5)
            make.height.equalTo(forwardButton).multipliedBy(0.6)
        }
        
        sepRight.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(forwardButton)
            make.left.equalTo(commentButton.snp_right)
            make.size.equalTo(sepLeft)
        }
        
    }
    
    private func sepView() -> UIView {
        let v = UIView()
        v.backgroundColor = UIColor.blueColor()
        return v
    }
    
}



